package pl.pawluk.inz.dto;

import pl.pawluk.inz.entities.CourseEntity;
import pl.pawluk.inz.entities.UsersEntity;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

/**
 * Created with IntelliJ IDEA.
 * User: mandp
 * Date: 19.04.13
 * Time: 22:11
 * To change this template use File | Settings | File Templates.
 */
public class GroupDTO extends BaseDTO {
    private String groupName;
    private Set<UserDTO> members = new HashSet<UserDTO>();
    private Set<CourseDTO> courses = new HashSet<CourseDTO>();

    public String getGroupName() {
        return groupName;
    }

    public void setGroupName(String groupName) {
        this.groupName = groupName;
    }

    public Set<UserDTO> getMembers() {
        return members;
    }

    public Set<CourseDTO> getCourses() {
        return courses;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof GroupDTO)) return false;

        GroupDTO groupDTO = (GroupDTO) o;

        if (id != groupDTO.id) return false;
        if (courses != null ? !courses.equals(groupDTO.courses) : groupDTO.courses != null) return false;
        if (groupName != null ? !groupName.equals(groupDTO.groupName) : groupDTO.groupName != null) return false;
        if (members != null ? !members.equals(groupDTO.members) : groupDTO.members != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = (int) (id ^ (id >>> 32));
        result = 31 * result + (groupName != null ? groupName.hashCode() : 0);
        result = 31 * result + (members != null ? members.hashCode() : 0);
        result = 31 * result + (courses != null ? courses.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "GroupDTO{" +
                "id=" + id +
                ", groupName='" + groupName + '\'' +
                ", members=" + members +
                ", courses=" + courses +
                '}';
    }
}
